sfc "hash mismatch" and "source file in store is also corrupted"
As I understand it the sfc /scannow message "Could not reproject corrupted file ... source file in store is also corrupted" and "Cannot repair member file ... hash mismatch Hashes for file member ... do not match actual file" means that the file was corrupt but the %WinDir%\winsxs copy was also corrupt, so the file can't be repaired. Since Windows 6.0 sfc /scannow will not read from the installation media by default but instead read from %WinDir%\winsxs, but is there a way to force it to copy the file from the installation media? The sfc /scannow options /offbootdir and /offwindir is no help because it doesn't specifiy where to collect the files, it specifies the windows files to restore (instead of the default %WinDir%). Update: I created a manual solution by reading all hash mismatch failures from the CBS.log and copy the good files over the bad. Source in abridged version below (good files in C:, bad files in Z:), the full version (that can also read the files from the installation media) is found in this repo. using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Security.Principal; using System.Security.AccessControl; namespace sfcex { class sfcex { public static void TakeOwn(string pth) { Process p = new Process(); p.StartInfo.FileName = "takeown"; p.StartInfo.Arguments = String.Format("/f {0} /d y", file); p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; p.Start(); p.WaitForExit(); p.StartInfo.FileName = "icacls"; p.StartInfo.Arguments = String.Format("{0} /grant administrators:F /t", file); p.Start(); p.WaitForExit(); } static void Main(string[] args) { List<string> lines = new List<string>(); try { using (StreamReader sr = new StreamReader("CBS.log")) { String line, src, trg, pth; while ((line = sr.ReadLine()) != null) { if (line.IndexOf(" do not match") > 0) { src = line.Substring(line.IndexOf("\\"), line.IndexOf(" do not match") - line.IndexOf("\\")); src = src.Replace("\\SystemRoot", "C:\\Windows"); src = src.Replace("\\??\\", ""); trg = src.Replace("C:", "Z:"); pth = trg.Substring(0, trg.LastIndexOf("\\")); TakeOwn(pth); TakeOwn(trg); Console.WriteLine(String.Format("{0} : {1} : {2}", src, trg, pth)); try { System.IO.File.Copy(src, trg, true); } catch (Exception e) { Console.WriteLine(e.Message); } } } } } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Done. Press a key to continue . . ."); System.Console.ReadKey(); } } }
September 20th, 2011 5:57pm

Hi, Thanks for your update and sharing the solution.Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
September 22nd, 2011 3:44am

What kind of script is this? Also, is this to be ran in safe mode or repair mode? You also stated good files in C: and the bad in Z: Wouldn't bad files be in C: ( normal installation) and bad files Z: (if you remap your CD drive letter)? The website you linked to has no downloads available. Thank you for the insight however.
May 15th, 2012 7:55pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics